package com.goldenautumn.prefabricate.activity.mine.adapter

import android.content.Context
import android.view.ViewGroup
import com.blankj.utilcode.util.LogUtils
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.DataBindingHolder
import com.goldenautumn.prefabricate.R
import com.goldenautumn.prefabricate.activity.mine.LanguageActivity
import com.goldenautumn.prefabricate.activity.mine.NoticeActivity
import com.goldenautumn.prefabricate.activity.mine.UserInfoActivity
import com.goldenautumn.prefabricate.activity.mine.address.AddressManageActivity
import com.goldenautumn.prefabricate.business.entity.UserMenuVo
import com.goldenautumn.prefabricate.databinding.ItemUserMenuBinding
import com.goldenautumn.prefabricate.utils.clickIsLogin
import com.goldenautumn.prefabricate.utils.loadImgUrl
import qncx.external.common.utils.intent

class UserMenuAdapter : BaseQuickAdapter<UserMenuVo, DataBindingHolder<ItemUserMenuBinding>>() {

    override fun onBindViewHolder(holder: DataBindingHolder<ItemUserMenuBinding>, position: Int, item: UserMenuVo?) {
        if(item == null) return
        var mBinding  = holder.binding

        item.img?.let { mBinding.icon.setImageResource(it) }
        mBinding.title.text = item.name
    }

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): DataBindingHolder<ItemUserMenuBinding> {
        return DataBindingHolder(R.layout.item_user_menu,parent)
    }

    fun userMenuAction(type:String){
        when(type) {
            "1" -> {
                context.startActivity(UserInfoActivity::class.intent)
            }
            "2" -> {
                context.startActivity(LanguageActivity::class.intent)
            }
            "3" -> {
                context.startActivity(AddressManageActivity::class.intent)
            }
            "4" -> {
//                context.startActivity(AddressManageActivity::class.intent)
            }
            "5" -> {
                context.startActivity(NoticeActivity::class.intent)
            }
        }
    }

}